package com.uocmbuy.adver.common.advice;

import com.uocmbuy.adver.common.exception.AdverException;
import com.uocmbuy.adver.common.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by yaosheng on 2021/3/26.
 * 统一异常响应处理
 */
public class GlobalExceptionAdvice {

    @ExceptionHandler(value = AdverException.class)
    public CommonResponse<String> handlerAdException(HttpServletRequest req, AdverException ax) {

        CommonResponse<String> response = new CommonResponse<>(-1, "Business Error");
        response.setData(ax.getMessage());
        return response;
    }

}
